package core;
import java.awt.Cursor;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.geom.Point2D;

public abstract class DrawTool {

	public abstract void processMouseEvent(MouseEvent evt, DrawContext context);
	
	public abstract void processKeyEvent(KeyEvent evt, DrawContext context);
	
	public void configureMouseIcon(MouseEvent evt, DrawContext ctx, Cursor cursor){
		
		if(cursor == null) return;
		
		if(ctx.hasSelection()){
			
			Point2D.Double point = new Point2D.Double(evt.getX(), evt.getY());
			
			if(ctx.getSelectionShape().contains(point)){
				ctx.getCanvas().setCursor(cursor);
			}
			else{
				ctx.getCanvas().setCursor(Cursor.getDefaultCursor());
			}
			
		}
		else{
			ctx.getCanvas().setCursor(cursor);
		}
		
	}
	
	public abstract void dispose(DrawContext ctx);
	
	public abstract void init(DrawContext ctx);

}
